/*
 * Copyright (C) 2011 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package it.trekker.wifidirect;

import android.net.wifi.p2p.WifiP2pInfo;
import android.net.wifi.p2p.WifiP2pManager.ConnectionInfoListener;
import it.trekker.dataexchange.service.ClingDataExchangeService;

/**
 * A fragment that manages a particular peer and allows interaction with device
 * i.e. setting up network connection and transferring data.
 */
public class WiFiDirectConnectionInfoListener implements ConnectionInfoListener {


	@Override
	public void onConnectionInfoAvailable(final WifiP2pInfo info) {
		// After the group negotiation, we assign the group owner as the file
		// server. The file server is single threaded, single connection server
		// socket.
		if (info.groupFormed && info.isGroupOwner) {
			// Server: receive poi
		} 
		else if (info.groupFormed) {
			// Client
		}

		// Search the service and use it if exist
		ClingDataExchangeService dataExchange = ClingDataExchangeService.getInstance();
		if(dataExchange != null)
			dataExchange.search();

	}
}
